# delimit ;
clear ;
cd "replication" ;
set more off ; 

* *************************************************************************** ;
* re-run midline analysis
* *************************************************************************** ;

cd ".." ;
do "./replication/do/table04-endline-knowledge-aggregate.do" ; 

****************************************************************************** ;
* robustness check
****************************************************************************** ;

* excluding subjects assigned to counseling and/or goal setting ; 
drop if financial_counseling == 1 | financial_goal_setting == 1 ;

est drop _all ;

foreach var in module_all module1_know module23_know module4_know module5_know { ;
	
	areg `var' healthonly healthandpay, a(strata) robust ;
	qui est sto `var'; 
	
	test healthonly = healthandpay ; 
	estadd local titlerow = "" ; 
	estadd scalar fstat = r(F): `var' ; 
	estadd scalar pval = r(p): `var' ; 

	summarize `var' if control == 1 & e(sample) == 1;
	estadd scalar cmean = r(mean): `var' ; 
	estadd scalar csd = r(sd): `var' ;

} ;

esttab module* using "./output/appendix-table-endline-knowledge-aggregate-excluding-couns-goal.tex",
	replace
	drop(_cons) 
	cells(b(label() star fmt(%9.3f %9.3f)) se(par)) 
	star(* 0.10 ** 0.05 *** 0.01) 
	stats(titlerow fstat pval cmean csd N, fmt(%9s %9.3f %9.3f %9.3f %9.3f %9.0f) labels("\(F\)-test, HEE = HEEC" "$\qquad$ \(F\)-statistic" "$\qquad$ \(p\)-value" "Control Mean" "Control SD" "N"))
	prehead(\begin{table}[b!] \centering \small `"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"'
		\captionsetup{justification=centering} 
		\caption{Effects on Longer-Term Health Knowledge \\ Robustness Check, Pure Placebo Group}
		\label{appendix-table-endline-knowledge-aggregate-excluding-couns-goal}
		\begin{tabular*}{0.88\hsize}{p{3.8cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
		\toprule)
	legend label  booktabs  collabels( , none)
	mgroups(
	"All Topics" 
	"By Topic" 
	, pattern(1 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
	postfoot(`"\bottomrule"'  \end{tabular*} \captionsetup{justification=justified, width=0.88\hsize} 
		\caption*{\footnotesize \textit{Notes:} Re-estimation of Table \ref{table-endline-knowledge-aggregate},
		but excluding respondents in the placebo film group who were randomized into additional financial-related
		treatments (i.e., financial counseling and/or goal setting). Thus, the control group in this regression
		consists of respondents who were assigned to only financial films.
		***\$\,p < 0.01$, **\$\,p < 0.05$, *\$\,p<0.10$.
		}
		\end{table}) ;

exit ;



